<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .aspectration {
            background-color: gold;
            position: relative;
            /*因为容器所有子元素需要绝对定位*/
            height: 0;
            /*容器高度是由padding来控制，盒模型原理告诉你一切*/
            width: 50%;
        }

        .aspectration[data-ratio="16:9"] {
            padding-top: 56.25%;
        }

        .aspectration[data-ratio="4:3"] {
            padding-top: 75%;
        }

        .aspectration>* {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <div class="aspectration" data-ratio="16:9">
        <div>132</div>
    </div>
</body>

</html>